const { defineConfig } = require("@vue/cli-service");
const path = require("path");
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    host: "localhost",
    port: 3000,
    open: true,
    proxy: {
      // 所有以 /conner前缀开头请求 才会 做如下反向代理
      "/api": {
        target:
          "https://www.fastmock.site/mock/8bcbf3c11219ce917be99607705afb4b",
        changeOrigin: true,
        // 路径重写
        pathRewrite: {
          "^/api": "/api",
        },
      },
    },
    // 服务器请求 真实完整路径是  target+(没有前缀)pathRewrite之后的值+后面的path
  },
  lintOnSave: false,
  chainWebpack: (config) => {
    config.resolve.alias
      .set("@", path.join(__dirname, "src"))
      .set("@c", path.join(__dirname, "src/components"))
      .set("@v", path.join(__dirname, "src/views"))
      .set("@s", path.join(__dirname, "src/store"))
      .set("@a", path.join(__dirname, "src/api"))
      .set("@u", path.join(__dirname, "src/utils"))
      .set("@r", path.join(__dirname, "src/router"));
  },
});
